#!/usr/bin/env python
# encoding: utf-8

"""
@version: python3.7
@Author  : huangyi
@contact:  hy.dazui@qq.com
@Time    : 2020/1/13 2:03
@Describe: add Describe here
"""
from app.ast.ast import Ast
from app.expression.context import Context
from app.expression.nonterminal.func.between import Between
from app.expression.nonterminal.func.int import Int
from app.expression.nonterminal.func.list import List
from app.expression.nonterminal.func.sqrt import Sqrt
from app.expression.nonterminal.func.sum import Sum
from app.scanner.scanner import Scanner

if __name__ == '__main__':
    # expression = "(1+2*3-4)/1.5"
    expression = "1 in list(1,2)"
    token_list = Scanner().scan(expression)
    expression = Ast().parse(token_list)
    if expression:
        ctx = Context()
        ctx.func_dict["sum"] = Sum()
        ctx.func_dict["sqrt"] = Sqrt()
        ctx.func_dict["int"] = Int()
        ctx.func_dict["between"] = Between()
        ctx.func_dict["list"] = List()
        print(expression.interpret(ctx))
    else:
        print("not expression")
